package cn.xiangxiang.controller.goods;

import cn.xiangxiang.pojo.common.Result;
import cn.xiangxiang.pojo.goods.Para;
import cn.xiangxiang.service.goods.ParaService;
import com.alibaba.dubbo.config.annotation.Reference;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/para")
public class ParaController {

    @Reference
    private ParaService paraService;

    @RequestMapping("/findall")
    public List<Para> findAll(){
        return paraService.list();
    }


    @PostMapping("/findconditionpage")
    public Page<Para> findConditionPage(Integer startpage, Integer pagesize, @RequestBody Map<String,Object> map){
        return paraService.findConditionPage(startpage,pagesize,map);
    }

    @GetMapping("/findbyid")
    public Para findById(Integer id){
        return paraService.getById(id);
    }

    @PostMapping("/save")
    public Result save(@RequestBody Para para){
        paraService.save(para);
        return new Result();
    }

    @PostMapping("/update")
    public Result update(@RequestBody Para para){
        paraService.updateById(para);
        return new Result();
    }

    @GetMapping("/delbyid")
    public Result delById(Integer id){
        paraService.removeById(id);
        return new Result();
    }
}
